#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    int n;
    cin>>n;
    vector<int> arr(2*n);
    for(int i=0;i<2*n;i++){
        cin>>arr[i];
    }
    map<int,int> mp;
    vector<int> ans1,ans2;
    for(int i=1;i<=n;i++)mp[i]=1;
    for(int i=0;i<2*n;i++){
        if(mp[arr[i]]==1){
            mp[arr[i]]++;
            ans1.push_back(arr[i]);
        }
        else ans2.push_back(arr[i]);
    }
    for(int i=0;i<ans1.size();i++){
        if(i)cout<<" "<<ans1[i];
        else cout<<ans1[i];
    }
    cout<<endl;
    for(int i=0;i<ans2.size();i++){
        if(i)cout<<" "<<ans2[i];
        else cout<<ans2[i];
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    

    return 0;
}